﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using CSF.BusinessCore.BLL;
using CSF.Security.Data;
using Ict.DataAccess;

namespace CSF.Security.BLL
{
    public class UserAccountApplicationBLL : LogCreateLogic<UserAccountApplication>
    {
        internal bool CheckUser(int userId, string appCode)
        {
            var q = from p in DataContext.Select<UserAccountApplication>()
                    from p1 in DataContext.Select<Application>()
                    where p.UserId == userId && p1.Code == appCode
                    select p.UserId;
            return userId == q.FirstOrDefault();
        }

        internal bool CheckUser(int userId, int applicationId)
        {
            var q = from p in DataContext.Select<UserAccountApplication>()
                    where p.UserId == userId && p.ApplicationId == applicationId
                    select p.UserId;
            return userId == q.FirstOrDefault();
        }
    }
}
